//
//  CellForFocusNewsTopRoll.m
//  世界
//
//  Created by dllo on 16/3/3.
//  Copyright © 2016年 admin. All rights reserved.
//

#import "CellForFocusNewsTopRoll.h"
#import "ModelForFocusNews.h"
#import <UIImageView+WebCache.h>

@interface CellForFocusNewsTopRoll ()

@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UILabel *lableForTitle;

@end

@implementation CellForFocusNewsTopRoll


#pragma mark 重写dealloc方法
- (void)dealloc
{
    [super dealloc];
    
    [_imageView release];
    
    [_lableForTitle release];
}




#pragma mark 重写初始化方法
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self != nil)
    {
        //创建子控件
        self.imageView = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.imageView];
        
        [_imageView release];
        
        self.lableForTitle = [[UILabel alloc] init];
        
        [self.contentView addSubview:self.lableForTitle];
        
        [_lableForTitle release];
    }
    return self;
}


#pragma mark 布局子控件
//collectionCell 的子控件的布局通常在此方法中设置
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.imageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 40);
    
    self.lableForTitle.frame = CGRectMake(5, self.contentView.frame.size.height - 40 - 5, self.contentView.frame.size.width, self.contentView.frame.size.height - (self.contentView.frame.size.height - 40 - 5 - 5));
    
    //文字居中
    //self.lableForTitle.textAlignment = NSTextAlignmentCenter;
}


- (void)handleData:(ModelForFocusNews *)model
{
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.PicUrl] placeholderImage:[UIImage imageNamed:@"占位图"]];
    
    self.lableForTitle.text = model.Title;
}



@end
